import api from './index'
import { axios } from '@/utils/request'

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login(parameter) {
  return axios({
    url: api.Login,
    method: 'post',
    data: {
      userName: parameter.userName,
      password: parameter.password
    }
  })
}

export function getSmsCaptcha(parameter) {
  return axios({
    url: api.SendSms,
    method: 'post',
    data: parameter
  })
}

export function getInfo() {
  return axios({
    url: api.UserInfo,
    method: 'get'
  })
}

export function getCurrentUserNav(token) {
  return axios({
    url: api.CurrentUserNav,
    method: 'get'
  })
}

export function logout() {
  return axios({
    url: api.Logout,
    method: 'DELETE'
  })
}

export function getUserToken(query) {
  return axios({
    url: api.GetUserToken + '?userId=' + query.userId + '&refreshToken=' + query.refreshToken,
    method: 'GET'
  })
}

